<!DOCTYPE HTML>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>找到合适的值</title>
</head>

<body>
    <script>
        var arr = ['100px', 'abc' - 6, [], -98765, 34, -2, 0, '300', , function() {
            alert(1);
        }, null, document, [], true, '200px' - 30, '23.45元', 5, Number('abc'), function() {
            alert(3);
        }, 'xyz' - 90];
        var num = [];
        var toNum = [];
        var max;
        var nan = [];
        /*
            1、找到arr里所有的数字：-98765, 34, -2, 0, 5
            2、找到可以转成数字的：'100px', -98765, 34, -2, 0, '300', '23.45元',  5 
            3、把转成数字以后，最大值判断出来：300
            4、把 NaN 所在的位置找出来：1 14 17  19
        */

        for (var i in arr) {
            if (!isNaN(arr[i]) && typeof(arr[i]) == 'number') {
                num.push(arr[i]);
            }
            if (typeof(parseFloat(arr[i])) == 'number' && !(isNaN(arr[i]) && isNaN(parseFloat(arr[i]))) && !((typeof(arr[i]) == 'object') || typeof(arr[i]) == 'boolean')) {
                toNum.push(arr[i]);
            }
            if (typeof(arr[i]) == 'number' && isNaN(arr[i])) {
                nan.push(i);
            }
        }
        for (var i in toNum) {
            if (i == 0) {
                max = parseFloat(arr[i]);
            }
            if (max < parseFloat(arr[i])) {
                max = parseFloat(arr[i]);
            }
        }
        console.log(num);
        console.log(toNum);
        console.log(max);
        console.log(nan);
    </script>
</body>

</html>